//
//  AppDelegate.m
//  JianSi
//
//  Created by Sam on 2017/5/30.
//  Copyright © 2017年 AP-EC. All rights reserved.
//

#import "AppDelegate.h"


#import <IQKeyboardManager/IQKeyboardManager.h>//键盘

#import "SamTabbarController.h"

@interface AppDelegate ()<EMChatManagerDelegate>

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //AppKey:注册的AppKey，点击"应用概述"可以看到AppKey,粘贴过来就可以。
    //apnsCertName:推送证书名,填写你的开发证书或者发布证书名,就是上传到环信后台的两个中的一个,什么环境下测试使用什么环境的证书。
//    EMOptions *options = [EMOptions optionsWithAppkey:@"1192170530115873#jiansipersonal"];
//    options.apnsCertName = @"develop";
//    [[EMClient sharedClient] initializeSDKWithOptions:options];
//    [[EMClient sharedClient] registerWithUsername:@"a1" password:@"123456" completion:^(NSString *aUsername, EMError *aError) {
//        if(aError){
//            NSLog(@"注册失败");
//        }else{
//            NSLog(@"注册成功");
//        }
//    }];

    
    
    // 1.创建窗口
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    
    self.window.rootViewController = [[SamTabbarController alloc] init];
    //    self.window.rootViewController = mainNVC;
    
    //白色背景
    self.window.rootViewController.view.backgroundColor = [UIColor whiteColor];
    
    [UIApplication sharedApplication].keyWindow.backgroundColor = [UIColor whiteColor];
    
    [self.window makeKeyAndVisible];
    
    
    
    //设置键盘
    [self BA_KeyboardSetting];
    
    return YES;
}


// 将得到的deviceToken传给SDK
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
    [[EMClient sharedClient] bindDeviceToken:deviceToken];
}

// 注册deviceToken失败
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
    NSLog(@"error -- %@",error);
}

// APP进入后台
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [[EMClient sharedClient] applicationDidEnterBackground:application];
}

// APP将要从后台返回
- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [[EMClient sharedClient] applicationWillEnterForeground:application];
}


#pragma mark - ***** 键盘处理
- (void)BA_KeyboardSetting
{
    IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
    manager.enable = YES;
    manager.shouldResignOnTouchOutside = YES;
    manager.shouldToolbarUsesTextFieldTintColor = YES;
    manager.enableAutoToolbar = YES;
   }




@end
